package org.javabrains.koushik.hibernate;

import java.util.Date;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.javabrains.koushik.dto.Address;
import org.javabrains.koushik.dto.FourWheeler;
import org.javabrains.koushik.dto.TwoWheeler;
import org.javabrains.koushik.dto.UserDetails;
import org.javabrains.koushik.dto.Vehicle;

public class HibernateTest {
	
	public static void main(String args[]){
		
		//UserDetails user = new UserDetails();
		//user.setUserName("First User");
		//user.setAddress("First User address");
		
		
		Vehicle vehicle = new Vehicle();
		vehicle.setVehicleName("Car");
		
		
		TwoWheeler bike = new TwoWheeler();
		bike.setVehicleName("Bike");;
		bike.setSteeringHandle("Bike steering Handle");
		
		
		FourWheeler car = new FourWheeler();
		car.setVehicleName("Car");
		car.setSteeringWheel("Porsche steering wheel");
		
		
		
		
		
		//persist object
		
		SessionFactory sessionFactory = new Configuration().configure().buildSessionFactory();
		Session session = sessionFactory.openSession();
		session.beginTransaction();
		
		session.save(vehicle);
		session.save(bike);
		session.save(car);
		
		//session.persist(user);
		//session.save(vehicle);
		//session.save(vehicle2);
		
		session.getTransaction().commit();
		session.close();
				
		
		//close session factory
		session.getSessionFactory().close();
		
		
		
		//test
		
	}

}
